-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: user auth #47
feat: user auth #47
Conversation
990a1f4
to
b49e6ad
Compare
This is looking interesting ^_^ Going to take a closer look tomorrow. Sorry for the early review before you were done, I didn't realize it was still a draft |
@Hajbo FYI, I changed the description of this PR from "Issue #30" to "Closes #30", following Linking a pull request to an issue using a keyword |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good. I like how you handled the environment variables configuration using TypeBox. The usage is as simple as env.%myEnvironmentVariable%
which is typesafe and validated. Lovely!
I also like the clear separation of concerns by placing the auth.ts
in its own file.
Finally, I appreciate the error handling that you added as a bonus in this PR, and I think your approach for that is clean and sensible.
Questions
What is the motivation to not use the Elysia JWT Plugin?
Is it because it is cumbersome to set it up for our 3-tier architecture?
Next Steps
- Consider using env-schema to make the env validation even cleaner and more out of box. That library works well with typebox.
- Consider clarifying the responsibility of
auth.ts
by making it either one ofauth.middleware.ts
orauth.service.ts
. We should strive to stay true to our separation of concerns approach to avoid leaking responsibilities in the future as much as possible and keep the codebase robust. - See if we can make Swagger work or ditch it.
- There's quite a lot going on in the
users.schema.ts
file, which feels like a betrayal of the RealWorld concept. Sure, it works for a small project to put it all in one file, but in the spirit of a RealWorld application at scale I believe we should break it down into 2 or 3 granular pieces. We should consider putting thepgTable
in a.model.
or.entity.
file, and potentially even move the types to their own files too. RealWorld example here.
Co-authored-by: Yam Borodetsky <[email protected]>
The JWT plugin only puts some wrapper object to the request handler, we can't access it in a The current auth.js is a bunch of utility functions, it's neither middleware nor service. I'm not sure what's the Nestjs mentality about them though I wouldn't say that there are a lot going on, it's one place to prepare all the schemas/types for a user. They are super connected. Even if this file was 500 lines long they still are tightly coupled and IMHO should be together. Easier to maintain like this. The example you linked seems like a nightmare to work with with these 10 line files that contain nothing of value |
Great. While I'm saddened we're not using all Elysia has to offer, in reality we have to make some sacrifices in the face of (1) realizing that Elysia still has types and features missing (2) implementing things under the framework layer. It feels like Elysia is designed to be truly embraced by lighter applications, ones with less separation of concerns. Do you feel the same way?
Let's solve that separately in #52, I'm sure we can find a simple solution for this.
I understand where you're coming from, but I'm still quite concerned by putting tables and interfaces under |
Closes #30